package com.recruit.dao;

import com.recruit.entity.User;

import java.sql.SQLException;
/****
 * author:丁文彬
 * time：2020.9.25
 */

public class UserLoginAndResgitDao extends BaseDao<User> {

    //普通用户登录
    public User selectUserByUsernameAndPassword(String username,String password) throws SQLException {
        //sql
        String sql = "select * from user where username=? and password=?";
        //调用父类
        User user = this.getBean(User.class, sql, username, password);
        return user;
    }


    //普通用户注册
    public int insertUser(User user) throws SQLException {
        //sql
        String sql = "insert into user values(null,?,?,?,?,?,?)";
        //调用父类
        int index = this.update(sql, user.getUsername(), user.getPassword(), user.getEmail(), user.getPhone(), user.getAge(), user.getSex());
        return index;
    }



}
